package PTA3.ti8;

/**
 * @author Lenovo
 */

import java.util.*;

import java.util.*;

class Employee implements Comparable<Employee> {
    private int id;
    private String name;
    private String gender;
    private int groupInsurance;
    private int individualInsurance;

    public Employee() {}

    public Employee(int id, String name, String gender, int groupInsurance, int individualInsurance) {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.groupInsurance = groupInsurance;
        this.individualInsurance = individualInsurance;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }

    public int getGroupInsurance() {
        return groupInsurance;
    }

    public int getIndividualInsurance() {
        return individualInsurance;
    }

    public int getTotalPerformance() {
        return groupInsurance + individualInsurance;
    }

    @Override
    public int compareTo(Employee other) {
        return Integer.compare(this.getTotalPerformance(), other.getTotalPerformance());
    }

    @Override
    public String toString() {
        return id + "," + groupInsurance + "," + individualInsurance + "," + name + "," + gender;
    }
}

class GroupInsuranceComparator implements Comparator<Employee> {
    @Override
    public int compare(Employee e1, Employee e2) {
        return Integer.compare(e1.getGroupInsurance(), e2.getGroupInsurance());
    }
}

public class Main {
    public static void main(String[] args) {
        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee(1, "职工1", "female", 500, 400));
        employees.add(new Employee(2, "职工2", "female", 400, 600));
        employees.add(new Employee(3, "职工3", "male", 600, 300));
        employees.add(new Employee(4, "职工4", "female", 800, 200));
        employees.add(new Employee(5, "职工5", "male", 500, 700));


        Collections.sort(employees);
        System.out.println("编号,团险,个险,姓名,性别");
        for (Employee emp : employees) {
            System.out.println(emp);
        }

        Collections.sort(employees, new GroupInsuranceComparator());
        System.out.println("编号,团险,个险,姓名,性别");
        for (Employee emp : employees) {
            System.out.println(emp);
        }
    }
}
